<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="include::head"></head>
<body>
<div class="layui-fluid">
    <!--form表单-->
    <form class="layui-form">

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input th:if="${type != 'dictionaries'}" type="text" name="diyTypeName" th:value="${diyTypeDictionary.diyTypeName}" autocomplete="off" class="layui-input" lay-verify="required">
                <input th:if="${type == 'dictionaries'}" type="text" name="dictionaryName" th:value="${diyTypeDictionary.dictionaryName}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">标识</label>
            <div class="layui-input-block">
                <input th:if="${type != 'dictionaries'}" type="text" name="diyTypeRoute" th:value="${diyTypeDictionary.diyTypeRoute}" autocomplete="off" class="layui-input" lay-verify="required">
                <input th:if="${type == 'dictionaries'}" type="text" name="dictionaryRoute" th:value="${diyTypeDictionary.dictionaryRoute}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item" th:if="${type == 'dictionaries'}">
            <label class="layui-form-label">字典类型</label>
            <div class="layui-input-block">
                <select name="typeId" lay-verify="required">
                    <th:block th:each="typeList : ${typeList}">
                        <option th:if="${diyTypeDictionary.typeId == typeList.diyTypeId}" th:value="${typeList.diyTypeId}" th:utext="${typeList.diyTypeName}" selected = "selected" ></option>
                        <option th:if="${diyTypeDictionary.typeId != typeList.diyTypeId}" th:value="${typeList.diyTypeId}" th:utext="${typeList.diyTypeName}"></option>
                    </th:block>>
                </select>
            </div>
        </div>

        <div class="layui-form-item" th:if="${type == 'dictionaries'}">
            <label class="layui-form-label">样式</label>
            <div class="layui-input-block">
                <input type="text" name="dictionaryClass"  th:value="${diyTypeDictionary.dictionaryClass}" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <th:block th:each="value,iterStat: ${diy['state_type']}">
                        <input th:if="${value.dictionaryRoute==diyTypeDictionary.isState}" type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}"  checked  >
                        <input th:if="${value.dictionaryRoute!=diyTypeDictionary.isState}" type="radio" name="isState" th:value="${value.dictionaryRoute}" th:title="${value.dictionaryName}">
                </th:block>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remarks" th:utext="${diyTypeDictionary.remarks}" class="layui-textarea"></textarea>
            </div>
        </div>
        <input type="hidden" th:value="${type}"  name="showType">

        <input th:if="${type != 'dictionaries'}" type="hidden" th:value="${diyTypeDictionary.diyTypeId}"  name="diyTypeId">
        <input th:if="${type == 'dictionaries'}" type="hidden" th:value="${diyTypeDictionary.dictionaryId}"  name="dictionaryId">

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div id="alert-tree" style="display: none">
    <div class=""  id="tree">loding... ...</div>
</div>
<div th:include="include::onload"></div>
<script  th:inline="javascript">
    layui.config({
        base: '/js/layer/module/'//模块存放的目录
    }).use(['form','verify'], function(){
        var form = layui.form,
            verify = layui.verify;
        verify.verification();

        // 监听提交
        form.on('submit(edit)', function(data) {
            $.achieve.post("/admin/basics/dictionaries/update",data.field,"",true);
            return false;
        });

    });
</script>
</body>
</html>